import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;

import com.ltc.cdr.connector.download;




public class MainProgram {
	
	
	public static void startProgress(final String Statusday,final String RootTree,final String User,final String Pass,final String Host,final String RootPath,final String Filter,final String PathDownload,final String PathConvert,final String FTPPath,final String Types) {
	
		Runnable runnable = new Runnable() {
			download d = new download();
			public void run() {

				
					
					try {
						download.CheckFile(RootTree);
						download.CheckFile(RootPath);
						download.CheckFile(PathDownload);
						download.CheckFile(PathConvert);
						System.out.println(d.DownloadAction(Host, User, Pass, PathDownload,FTPPath,Filter,PathConvert,Types,Statusday));
						Thread.sleep(100);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					//System.out.println("Complete....Proccess!");
				}
			
		};
		new Thread(runnable).start();
	}

	public static void main(String[] args) {
		//args[0].toString()
		Timer myTimer;
		myTimer = new Timer();
		Calendar c = Calendar.getInstance();
		System.out.println("Start.......Running... of Date: " + c.getTime() +"\n\n");
		
		myTimer.schedule(new TimerTask() {
			public void run() {
				
				
				
		
		
		String RootTree ="D:\\CDRData";
		Calendar c = Calendar.getInstance();
		SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
		SimpleDateFormat f = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");
		String Filter ="b"+df.format(c.getTime());
		String RootPath=RootTree+"\\DataFTP_"+df.format(c.getTime());
		//String Dates ="";
		Calendar cal = Calendar.getInstance();
		cal.add(Calendar.DATE, -1);
		String RootPathPreDay=RootTree+"\\DataFTP_"+df.format(cal.getTime());
		String FilterPreDay ="b"+df.format(cal.getTime());
		
		
		
		File file =new File(RootPath);
		
		if(!file.exists())
		{
			
			
			String User2g="bc";
			String Host2g ="192.9.200.248";
			String Pass2g="BC";
			String PathDownload2g=RootPathPreDay+"\\2gData";
			String PathConvert2g=RootPathPreDay+"\\ConvertData2g";		
			String FTPPath2g= "R4/scdr/";
			
			//2g
			startProgress(f.format(cal.getTime()),RootTree,User2g,Pass2g,Host2g,RootPathPreDay,FilterPreDay,PathDownload2g,PathConvert2g,FTPPath2g,"Data2G");
			
		
			String User="billing";
			String Host ="192.9.200.218";
			String Pass="billing";
		
			String PathDownload3g=RootPathPreDay+"\\3gData";
			String PathConvert3g=RootPathPreDay+"\\ConvertData3g";
			String FTPPath3g="ap2/second/scdr/";
			//3g
			
			startProgress(f.format(cal.getTime()),RootTree,User,Pass,Host,RootPathPreDay,FilterPreDay,PathDownload3g,PathConvert3g,FTPPath3g,"Data3G");
			
			
			
			String PathDownload4g=RootPathPreDay+"\\4gData";
			String PathConvert4g=RootPathPreDay+"\\ConvertData4g";		
			String FTPPath4g= "ap1/second/pgwcdr/";
			
			
			//4g
			startProgress(f.format(cal.getTime()),RootTree,User,Pass,Host,RootPathPreDay,FilterPreDay,PathDownload4g,PathConvert4g,FTPPath4g,"Data4G");
			
			
		}
		
		
		String User2g="bc";
		String Host2g ="192.9.200.248";
		String Pass2g="BC";
		String PathDownload2g=RootPath+"\\2gData";
		String PathConvert2g=RootPath+"\\ConvertData2g";		
		String FTPPath2g= "R4/scdr/";
		
		//2g
		startProgress(f.format(c.getTime()),RootTree,User2g,Pass2g,Host2g,RootPath,Filter,PathDownload2g,PathConvert2g,FTPPath2g,"Data2G");
		
	
		String User="billing";
		String Host ="192.9.200.218";
		String Pass="billing";
	
		String PathDownload3g=RootPath+"\\3gData";
		String PathConvert3g=RootPath+"\\ConvertData3g";
		String FTPPath3g="ap2/second/scdr/";
		//3g
		
		startProgress(f.format(c.getTime()),RootTree,User,Pass,Host,RootPath,Filter,PathDownload3g,PathConvert3g,FTPPath3g,"Data3G");
		
		
		
		String PathDownload4g=RootPath+"\\4gData";
		String PathConvert4g=RootPath+"\\ConvertData4g";		
		String FTPPath4g= "ap1/second/pgwcdr/";
		
		
		//4g
		startProgress(f.format(c.getTime()),RootTree,User,Pass,Host,RootPath,Filter,PathDownload4g,PathConvert4g,FTPPath4g,"Data4G");
		
	
		
			}
		}, 0, 200000);
	
	}

}
